Ritu Singh
You can do the following to modify the AddPost method:
Create a detached Blog entity and set its Id property to match the Blog ID in the newPost object.
Attach the detached Blog entity to the context or set its state to Unchanged.
Add the new post to the context.
Here's an example of how you can modify your AddPost method to achieve this:
Suggested blogs:
>Testing react components using Hooks and Mocks
>Use Firebase Realtime Database with ASP.NET MVC App
>Setting up a Cloud Composer environment: Step-by-step guide
>Built Web API using ASP.NET (C#)
>Plugins and Presets for Vuejs project
>How to Create an array based on two other arrays in Php